import profile
import script.LuaPreprocessor as LuaPreprocessor
import script.LuaMerger as LuaMerger
import helpers.FileHelper as FileHelper
import helpers.MiscHelper as MiscHelper
import checkers.VersionChecker as VersionChecker
from package.PackageInterface import PackageInterface


class MVViewer(PackageInterface):

    def __init__(self, root_path, conf):
        PackageInterface.__init__(self, root_path, conf)


    def setup(self, opts):
        for k in opts:
            v = opts[k]
            # if k == "check-version":
            #     VersionChecker.check(self.conf, profile.mv_viewer_min_version)
            if k in ("D", "define"):
                LuaPreprocessor.preprocess(MiscHelper.parse_macros(v), self.path)
            elif k in ("m", "merge"):
                self.merge()
            elif k in ("h", "rehash"):
                self.rehash(profile.mv_viewer_min_version)
            elif k in ("s", "sign"):
                self.sign()


    def merge(self):
        root_path = FileHelper.solve_path(self.path, "src")
        return LuaMerger.merge(root_path, "MVEntry", FileHelper.solve_path(self.path, "layerAnimation.lua"))



